package _021_10_5

func search(nums []int, target int) int {

	left, right := 0, len(nums)-1

	for left <= right {
		mid := left + (right-left)/2
		if nums[mid] == target {
			for 0 < mid {
				mid--
				if nums[mid] != target {
					return mid + 1
				}
			}
		} else if nums[mid] < target {
			left = mid + 1
		} else {
			right = mid - 1
		}

	}
	return -1
}
